﻿using System;
using System.Windows;
using System.Data;
using System.Xml;
using System.Configuration;

using ExchangeRateService.ViewModel;

namespace ExchangeRateService
{
	/// <summary>
	/// Interaction logic for App.xaml
	/// </summary>
	public partial class App : Application
	{
		protected override void OnStartup(StartupEventArgs e)
		{
			base.OnStartup(e);

            MainWindow wnd = new MainWindow();

            // Create the ViewModel to which 
            // the main window binds.
            String path = "Data/rates.xml";
            var vm = new MainWindowViewModel(path);

            // When the ViewModel asks to be closed, 
            // close the window.
            EventHandler handler = null;
            handler = delegate
            {
                vm.RequestClose -= handler;
                wnd.Close();
            };
            vm.RequestClose += handler;

            // Allow all controls in the window to 
            // bind to the ViewModel by setting the 
            // DataContext, which propagates down 
            // the element tree.
            wnd.DataContext = vm;

            wnd.Show();
		}
	}
}